package vn.edu.nuce.dao;

import org.hibernate.Query;
import org.hibernate.SessionFactory;

import vn.edu.nuce.model.User;

public class LoginDaoImpl implements LoginDao{
	SessionFactory sessionFactory;

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	public User getUserName(String tenDangNhap,String matKhau) {
		String queryString = "FROM User WHERE ten_dang_nhap = ? and mat_khau = ?";
		Query hql = getSessionFactory().getCurrentSession().createQuery(queryString);
		hql.setParameter(0, tenDangNhap);
		hql.setParameter(1, matKhau);
		return (User) (hql.list().get(0));
	}

}
